<extend name="_Layout/main"/>

<block name="main">
<style type="text/css">
		[class*=am-u-]{padding-left:0;padding-right: 0;}
	.coin_hint {margin-top: 0;	border: 0;}
	.kstyle-btn {float: right;color: #333;}
	.kstyle-btn span {border: 1px solid #dcdcdc;height: 24px;line-height: 24px;text-align: center;font-size: 12px;
		padding: 0px 10px;display: inline-block;cursor: pointer;background: #f8f8f8;}
	.kstyle-btn span:hover {color: #ff6600;}
	span.kbtn-active {color: #ff6600;background: #fff;}
	.k-pro {width: 998px;border: 1px solid #ddd;}
	.my_coin_trade {color: #2471cb;	text-decoration: underline;font-size: 12px;}
	.my_coin_trade:hover {color: #f60;}
	.new_button {background: #f70 none repeat scroll 0 0;border-radius: 5px;color: #fff;display: block;
		font-size: 16px;height: 48px;line-height: 48px;	text-align: center;	width: 150px;}
	#show1 p {font-size: 14px}
	a:hover {color: #fff;}
	.exchange-center table{font-size: 12px;}
	.m-left1 th,.m-left1 td{ padding:0 !important; margin: 0 !important;}
	.m-left1{ line-height: 30px;}
	.exchange-center .am-table-bordered, .exchange-center .am-table-bordered>tbody>tr>td, .exchange-center .am-table-bordered>thead+tbody>tr:first-child>td{ line-height: 30px; background: #fdfbfb;}
	.uwidth1{ width:auto;}
	.exchange-center .am-table>thead>tr>th{ font-size: 14px; line-height: 40px;}
	.exchange-center{ width:1000px; margin:0 auto; height: auto; overflow: hidden;}
	.pay,.trading{ width:630px!important;}
	
		</style>
		<section class="banner">
			<img src="./Application/Home/View/default/_Resource/img/banner3.png" />
		</section>
		<section class="exchange-center">
			<div class="am-breadcrumb-bg">
				<div class="uwidth1">
					<ol class="am-breadcrumb am-text-right">
					  <li><a href="#">首页</a></li>
					  <li><a href="#">分类</a></li>
					  <li class="am-active">内容</li>
					</ol>
				</div>
			</div>
			<div style="clear:both;">
			<iframe id="chartID"  SCROLLING="NO" src="./Application/Home/View/default/Orders/index.html" style=" border:none;width:100%;height:600px;"></iframe>
			</div>
			<div class="uwidth1 am-posre" style=" margin-bottom: 50px; height: auto; overflow: hidden;">
			
			<div class="my_coin"> 
		        <!--登录后-->
		        <notempty name="userinfo">
		          <ul>
		            <li style="width: 200px; overflow: hidden; height: 24px;">我的{$currency.currency_name|default="虚拟币"} 资产：</li>
		            <li>可用：<span class="sell" id="from_over">{$user_currency_money['currency']['num']|default=0.00}</span></li>
		            <li>冻结：<span class="buy" id="from_lock">{$user_currency_money['currency']['forzen_num']|default=0.00}</span></li>
		            <li>总量：<span style="color:#333;" id="from_total">{$user_currency_money['currency']['num']+$user_currency_money['currency']['forzen_num']}</span></li>
		            <div class="clear"></div>
		          </ul>
		          <ul>
		            <li style="width: 200px; overflow: hidden; height: 24px;">我的{$currency_trade.currency_name|default="人民币"}资产：</li>
		            <li>可用：<span class="sell" id="to_over">{$user_currency_money['currency_trade']['num']|default=0.00}</span></li>
		            <li>冻结：<span class="buy" id="to_lock">{$user_currency_money['currency_trade']['forzen_num']|default=0.00}</span></li>
		            <li>总量：<span style="color:#333;" id="to_total">{$user_currency_money['currency_trade']['num']+$user_currency_money['currency_trade']['forzen_num']}</span></li>
		            <div class="clear"></div>
		          </ul>
		          <else/>
		          <p>我的资产：<a href="{:U('Home/User/login')}">登录</a> | <a href="{:U('Home/User/register')}">注册</a></p>
		        </notempty>
      		</div>
			
				<div class="m-left1 am-text-center" style="width:350px; float: left; margin-right: 20px;">
					
					<table class="am-table am-table-striped am-table-bordered am-table-compact" >
					  	<thead>
					  		<tr>
							    <th>成交时间</th>
							    <th>类型</th>
							    <th>价格</th>
							    <th>成交量</th>
							    <th>总计</th> 
					  		</tr>
					  	</thead>
					  	<tbody>
					  	<volist name="new_curorder" id="vo">
					  	
					  		<tr>
					    		<td>{$vo['ctime']}</td>
					    		<td>{$vo['type']}</td>
					   	 		<td>{$vo['price']}</td>
					   	 		<td>{$vo['num']}</td>
					   	 		<td>{$vo['totalMoney']}</td>
					  		</tr>
				  		</volist>
					  	</tbody>
					</table>
				</div>
				<div class="m-right"  style=" padding: 0; margin: 0; float: right;width:630px">
	<input type="hidden" id="curId" value="{$currency['id']}"/>
	<input type="hidden" id="userId" value="{$uinfo['uid']}"/>
	<input type="hidden" id="wsturl" value="{$wsturl}"/>
		<div id="main" style="background:#fbfaf8; padding-top:0; ">			
			<div class="main_box">
				<div class="trading left clearfix">
					<div class="curve pay">
						<div class="buysell sellform">
							<div class="buyformarea left">
								<h2 class="buy">买入{$currency['currency_name']}</h2>
								<ul class="buyform">
									<li><label>最佳买价：</label>
										<h3 id='coinbuy_nice' class="buy left">{$sell_record[count($sell_record)-1]['price']}</h3>
										<span style="padding-left:0px;">CNY</span>
									</li>
									<li><label for="price" class="buys">买入价格：</label>
										<input type="text" name="price" id="coinpricein" onkeyup="vNum(this,2);coinbuy_max(this.value,'btc',{$uinfo['money']});"><!-- sumbuy(0.00100,2); -->
									</li>
									<li><label for="num" class="buys">最大可买：</label>
										<b id="coinbuy_max" onclick="$('#numberin').val(this.innerHTML,'cny')" title="点击将数值写入数量输入框">0</b><span></span>
									</li>
									<li><label for="num" class="buys">买入比例：</label>
										<div id="buy-SliderVal" class="ratio">0%</div>
										<div id="buy-slider" data_slide='buy'></div>
									</li>
									<li><label for="buynum" class="buys">买入数量：</label>
										<input style="display:none;">
										<!-- for disable autocomplete on chrome -->
										<input type="text" class="coinbuy-number" name="buynum" id="numberin" onkeyup="vNum(this,4);sumbuy({$currency.currency_buy_fee|default="0"},2);" autocomplete="off" />
									</li>
									<li>
										<label for="buyword" class="buys">交易密码：</label>
										<input style="display:none;">
										<!-- for disable autocomplete on chrome -->
										<input type="password" class="buyinput" id="pwdtradein" autocomplete="off" />
									</li>
									<li style="margin-bottom:0;"><label for="num" class="buys">手续费：</label><b id='feebuy'>0.00</b><span>（{$currency.currency_buy_fee|default="0.00"}% {$currency.currency_mark|default="--"}）</span></li>
									<li><label for="num" class="buys">交易额：</label><b id="coinin_sumprice">0.00</b> CNY</li>
								</ul>
								<p class="sellform"><input type="button" id="trustbtnin"  class="submit" value="买入" /></p><!-- onclick="tcoinSubmit('btc2cny', 'in');mycointrust();" -->
								<p class="sellform" style="margin:15px 0;height:40px;"><span id="trustmsgin" class="tishi" style="display: table-cell;">数字货币交易具有极高的风险，投资需谨慎！</span></p>
							</div>
							<div class="buyformarea right">
								<h2 class="sell">卖出{$currency['currency_name']}</h2>
								<ul class="buyform sellform">
									<li><label>最佳卖价：</label>
										<h3 id='coinsale_nice' class="sell left">{$buy_record[0]['price']}</h3>
										<span style="padding-left:0px;">CNY</span>
									</li>
									<li><label for="price" class="buys">卖出价格：</label>
										<input type="text" class="buyinput" id="coinpriceout" onkeyup="vNum(this,2);"><!-- sumsale(0.00100,2); -->
									</li>
									<li><label for="num" class="buys">最大可卖：</label>
									<b id="coinsale_max"  title="">{$sell_num}</b><span></span>
										
										<!-- <b id="coinsale_max" onclick="$('#numberout').val(this.innerHTML)" title="点击将数值写入数量输入框">0</b> -->
									</li>
									<li><label for="num" class="buys">卖出比例：</label>
										<div id="sale-SliderVal" class="ratio">0%</div>
										<div id="sale-slider" data_slide='sale'></div>
									</li>
									<li><label for="buynum" class="buys">卖出数量：</label>
										<input style="display:none;">
										<!-- for disable autocomplete on chrome -->
										<input type="text" class="buyinput coinsale-number" name="outnum" id="numberout" onkeyup="vNum(this,4);sumsale({$currency.currency_sell_fee|default="0"},2);" autocomplete="off" />
									</li>
									<li><label for="buyword" class="buys">交易密码：</label>
										<input style="display:none;">
										<!-- for disable autocomplete on chrome -->
										<input type="password" class="buyinput" id="pwdtradeout" autocomplete="off" />
									</li>
									<li style="margin-bottom:0;"><label for="num" class="buys">手续费：</label><b id='fee'>0.00</b><span>（{$currency.currency_sell_fee|default="0.00"}% cny）</span></li>
									<li><label for="num" class="buys">交易额：</label>
										<b id="coinout_sumprice">0.00</b> CNY</li>
								</ul>
								<p class="sellform2">
									<input type="button" class="submit" id="trustbtnout" value="卖出"  /><!-- onclick="tcoinSubmit('btc2cny', 'out');mycointrust();" -->
								</p>
								<p class="sellform" style="margin:15px 0;height:40px;"><span id="trustmsgout" class="tishi" style="display: table-cell;">数字货币交易具有极高的风险，投资需谨慎！</span></p>
							</div>
							<div class="clear"></div>
						</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		</div>

	<link rel="stylesheet" type="text/css" href="./Application/Home/View/default/_Resource/css/subpage.css" />

	<script type="text/javascript" src="./Application/Home/View/default/_Resource/js/downList.js"></script>
	<script src="./Application/Home/View/default/_Resource/js/jquery.cookie.js" type="text/javascript"></script>
		<script>
			onlineUsers = {
				userid: '3652c69d94af83b89cc80cc5e7d10985',
				type: 'btc2cny'
			};
			isOnline = 'online';
		</script>
		<script src="./Application/Home/View/default/_Resource/js/coinindex.js"></script>
		<script src="./Application/Home/View/default/_Resource/js/socket.io.js"></script>
		<script>
			b2width = 3;
			user = {
				uid: 0,
				ybc_over: 0,
				ybc_lock: 0,
				cny_over: 0,
				cny_lock: 0,
				btc_over: 0,
				btc_lock: 0,
				ltc_over: 0,
				ltc_lock: 0,
				trmb_over: 0,
				trmb_lock: 0,
				email: '',
				name: ''
			};
		</script>
		<script>
			coin.name = 'btc2cny';
			coin.to = 'cny';
			btcprice = 19382.83, ybcprice = 14.09;
			socketConnection(50, 2, '比特币');
		</script>
		<script src="./Application/Home/View/default/_Resource/js/jquery.cookie.js"></script>
		<script src="./Application/Home/View/default/_Resource/js/slider.js"></script>
		<script>
			$(function() {
				$("#coinsalelist").on('mouseover', 'tr', function() {
					$(this).css('cursor', 'pointer');
				});
				$("#coinbuylist").on('mouseover', 'tr', function() {
					$(this).css('cursor', 'pointer');
				});
				$("#coinsalelist").on('click', 'tr', function() {
					$("#coinpricein").val($(this).find('td:nth-child(2)').text());
					$("#coinpriceout").val($(this).find('td:nth-child(2)').text());
					//$("#numberin").val($(this).find('td:nth-child(3)').text());
				});
				$("#coinbuylist").on('click', 'tr', function() {
					$("#coinpricein").val($(this).find('td:nth-child(2)').text());
					$("#coinpriceout").val($(this).find('td:nth-child(2)').text());
					//$("#numberout").val($(this).find('td:nth-child(3)').text());
				});
				// 买入/卖出 比例
				function slider() {
					var type = ['sale', 'buy'];
					for(var i in type) {
						var numcoin = parseFloat($("input.coin" + type[i] + "-number").val(), 2);
						var maxnum = parseFloat($("#coin" + type[i] + '_max').text(), 2);
						var per = Math.floor(numcoin * 100 / maxnum, 2, 0);
						
						if(isNaN(per)) {
							per = 0;
						}
						if(per > 100) {
							per = 100;
						}
						$("input.coin" + type[i] + "-number").unbind('input').on("input", function() {
							slider();
						});
						$("#" + type[i] + "-SliderVal").html(per + "%");
						$("#" + type[i] + "-slider").slider({
							range: "min",
							value: per,
							min: 0,
							max: 100,
							step: 10,
							slide: function(event, ui) {
								var type = $(ui.handle).attr('data_slide');
								var e = parseFloat($("#coin" + type + '_max').text());
								if(isNaN(e)) e = 0;
								if(ui.value == 100) {
									$("input.coin" + type + "-number").val(e);
								} else {
									var length = 4;
									$("input.coin" + type + "-number").val(formatfloat(e * ui.value / 100, length));
								}
								if(type == "buy") {
									sumbuy({$currency.currency_buy_fee|default="0"}, 2);
								} else {
									sumsale({$currency.currency_sell_fee|default="0"}, 2);
								}
								$("#" + type + "-SliderVal").html(ui.value + "%");
							}
						});
					}
				}
				slider();

			})
		</script>
		<script>
		$('#trustbtnin').click(function(){
			var price=$('#coinpricein').val();
			var num=$('input[name=buynum]').val();
			var pwd=$('.buyinput').val();
			var fee=$('#feebuy').html();
			var sumprice=$('#coinin_sumprice').html();
			var curId=$('#curId').val();
			if($("#coinpricein").val()==""){
				$("#trustmsgin").text("买入价格不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#numberin").val()==""){
				$("#trustmsgin").text("买入数量不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#pwdtradein").val()==""){
				$("#trustmsgin").text("交易密码不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if(($("#coinpricein").val())*($("#numberin").val())<1){
				$("#trustmsgin").text("交易额不能低于1元").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#userId").val()==""){
				$("#trustmsgin").text("请先登录再进行此操作！").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if(price && num && pwd){
				var url="{:U('Home/Trade/buy')}";
				$.getJSON(url,{price:price,num:num,pwd:pwd,fee:fee,sumprice:sumprice,curId:curId},function(json){
					if(json.status>0)
						{
							layer.msg(json.info);
							 setTimeout(function(){
								location.reload();
								},2000);
						}else{
							layer.msg(json.info);
						}
			    });	
				
			}
		});
		</script>
			<script>
		$('#trustbtnout').click(function(){
			var sellprice=$('#coinpriceout').val();
			var sellnum=$('input[name=outnum]').val();
			var sellpwd=$('#pwdtradeout').val();
			var sellfee=$('#fee').html();
			var sellsumprice=$('#coinout_sumprice').html();
			var curId=$('#curId').val();
			if($("#coinpriceout").val()==""){
				$("#trustmsgout").text("卖出价格不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#numberout").val()==""){
				$("#trustmsgout").text("卖出数量不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#pwdtradeout").val()==""){
				$("#trustmsgout").text("交易密码不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if(($("#coinpriceout").val())*($("#numberout").val())<1){
				$("#trustmsgout").text("交易额不能低于1元").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if($("#userId").val()==""){
				$("#trustmsgout").text("请先登录再进行此操作！").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
				return false;
			}
			if(sellprice && sellnum && sellpwd){
				var url="{:U('Home/Trade/sell')}";
				$.getJSON(url,{sellprice:sellprice,sellnum:sellnum,sellpwd:sellpwd,sellfee:sellfee,sellsumprice:sellsumprice,curId:curId},function(json){
					if(json.status>0)
						{
							layer.msg(json.info);
							 setTimeout(function(){
								location.reload();
								},2000);
						}else{
							layer.msg(json.info);
						}
			    });	
				
			}
		});
		</script>
	
					</div>
			</div>
		</section>
</block>